// pages/user/account/audit/audit.js
const config = getApp().globalData.config
const T = getApp().globalData.T
let token = ''
Page({

  /**
   * 页面的初始数据
   */
  data: {
      id: -1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.data.id = options.id;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    token = getApp().globalData.token;
    this.getDetail();
  },

  getDetail() {
    T.req({
      loadTitle: '加载中...',
      url: config.api + 'user/checked',
      method: 'GET',
      data: {
        token: token,
        checkedHrId: this.data.id
      },
      success: (res) => {
        this.setData({
          obj: res
        })
      }
    })
  },

  onOperate(e) {
    let _t = e.currentTarget.dataset.type == 1 ? 1 : 0;
    let param = {
      token: token,
      type: _t,
      checkedHrId: this.data.id
    }
    T.req({
      loadTitle: '请求中...',
      url: config.api + 'user/checked?' + T.param(param),
      method: 'PUT',
      success: (res) => {
        T.toast({ id: '#toast', text: '操作成功', success: ()=> {
          wx.navigateBack({
            delta:1
          })
        } });
      }
    })

  },
  
})